package gold.digger;

import java.util.*;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC594 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int findLHS(int[] nums) {
            Map<Integer, Integer> map = new HashMap<>();
            for (int i : nums) map.put(i, map.getOrDefault(i, 0) + 1);
            int ans = 0;
            for (int i : nums) {
                if (map.containsKey(i - 1)) {
                    ans = Math.max(ans, map.get(i) + map.get(i - 1));
                }
            }
            return ans;
        }
    }


    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC594 an = new LC594();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
